Twistpad Help   

Sdf File Definition

Introduction

The syntax file (SDF) is the heart of syntax specific capabilities of Twistpad.
All SDF files are located in the sub-folder "Syntax" of the main Twistpad folder.
It's the SDF files which define how a syntax is applied to a particular file (identified by it's extension)

The syntax of the SDF file is very similar to a standard Windows INI file. If you are familiar with this type of file, it should be easier to edit SDF files.
Although a very complex file syntax can be archived in Twistpad, the ease of creation of a new syntax it's one of the many strengths you can find in Twistpad. In 2 minutes you can create a new syntax file, simply based on keywords.
There are 3 main blocks in a SDF file, the [::Header::] which can be only one, and is not optional, and several sets of optional keywords and start-stop sections.

Header section

The header section is required to proper enable syntax for a specific file type in Twistpad.
The header is always : [::Header::]
The keywords for the Header section are:

Sections

There are two types of sections, Start-Stop Sections and Keywords Section.
Start-Stop Sections define a text color/format for, as the name implies, a block of text with recognized tokens. for instance you could say you want everything that starts with { and ends with } in blue.
Keywords define a single word which is to be colored, for instance, you might want that the word "Blue" appears in blue.
Both have the following Keywords:

Specific StartStop Keywords

Specific Keywords Keywords

Example

As a simple example let's say that you wish to have the words Twistpad, Syntax and File in blue.
Also everything between { and } in bold red. And as a final touch in our example let's define the word Color to be displayed in green only when it's between { and }.
Point to new file in Twistpad, create the header that should be something like:

[::Header::]
SyntaxName=Test syntax
extensions=tst
Now, as a rule, although this is not required, you should declare the start stop sections first. So we need to declare the brackets section

[Brackets]
Type=StartStop
Context=1
Scope=0
Priority=7
First={
Last=}
Background=Default
Foreground=FF0000
Bold=1
Now on to the keywords:

[BlueKeywords]
Type=keyword
Context=100
Scope=0
Priority=6
WholeWordOnly=1
Keyword1=Twistpad;Syntax;File
Background=Default
Foreground=0000FF

[GreenColorOnBrackets]
Type=keyword
Context=101
Scope=1
Priority=6
WholeWordOnly=1
Keyword1=Color
Background=Default
Foreground=008000

Notice the scope set to 1 on [GreenColorOnBrackets], this is to force the use of this style only in context 1 (between brackets)

Save the file as Test.sdf on the Syntax sub-folder of Twistpad and open a file with the tst extension to test the syntax just created.

Tips

The best way to make a new syntax is to modify an existing one, you can find all syntax definition files used by Twistpad in the sub folder "Syntax" in the "All Users Application Data" folder (Or double click the syntax screen on the Twistpad preferences dialogue).
In the Carthago Software Site, you may find more syntax files, the chances are you will not need to create any SDF file, as someone might already created it!

Notes

* Denotes a required keyword
** Context's are explained in the StartStop and Keywords section


© 1998 - 2008 Carthago Software. All rights reserved.